package com.kk.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 性别枚举
 *
 * @author kl
 */
@Getter
@AllArgsConstructor
public enum GenderEnum implements BaseEnum<Integer> {

    /**
     * 未知
     */
    UNKNOWN(0, "未知"),

    /**
     * 男
     */
    MALE(1, "男"),

    /**
     * 女
     */
    FEMALE(2, "女");

    @EnumValue
    @JsonValue
    private final Integer value;

    private final String label;

    private static final Map<Integer, GenderEnum> VALUE_MAP =
            Arrays.stream(values())
                    .collect(Collectors.toMap(GenderEnum::getValue, e -> e));

    public static GenderEnum of(Integer value) {
        return VALUE_MAP.get(value);
    }
}